clear
capture restore
set scheme cleanplots, perm

* SET DIRECTORIES
global home "..."

global data "$home/Data/"
global output "$home/Output/"

cd $home

********************************************************************************
********************************************************************************
********************************************************************************
use "${data}final_daily_data", clear
drop pre_crisis post_crisis crisis_flg

gen 	pre_crisis = (date < date("01JUL2008","DMY"))

gen 	post_crisis = (date > date("30JUN2009","DMY")) & !missing(date)

gen 	crisis_flg = (date >= date("01JUL2008","DMY") & date <= date("30JUN2009","DMY"))

keep if pre_crisis & fomc

egen date_tag = tag(day month year)

keep if date_tag

qui: outreg2 using "${output}tableA2_hf_daily.xls", excel dec(3) replace sum(log) eqkeep(N mean sd min max) keep(ff4 ff4_d mp1 mp1_d)

sum ff4 ff4_d mp1 mp1_d, detail

sum ff4 
replace ff4 = -ff4/r(sd)

sum ff4_d 
replace ff4_d = -ff4_d/r(sd)

sum mp1 
replace mp1 = -mp1/r(sd)

sum mp1_d 
replace mp1_d = -mp1_d/r(sd)

reg sp500 ff4 , robust 
outreg2 using "${output}tableA3.xml",  bdec(2) excel ctitle(sp500) replace
reg sp500 mp1 , robust
outreg2 using "${output}tableA3.xml",  bdec(2) excel ctitle(sp500) append

reg onrun2 ff4 , robust 
outreg2 using "${output}tableA3.xml",  bdec(2) excel ctitle(2 yr) append
reg onrun2 mp1 , robust 
outreg2 using "${output}tableA3.xml",  bdec(2) excel ctitle(2 yr) append

reg onrun5 ff4, robust
outreg2 using "${output}tableA3.xml",  bdec(2) excel ctitle(5 yr) append
reg onrun5 mp1, robust
outreg2 using "${output}tableA3.xml",  bdec(2) excel ctitle(5 yr) append

reg onrun10 ff4 , robust 
outreg2 using "${output}tableA3.xml",  bdec(2) excel ctitle(10 yr) append
reg onrun10 mp1 , robust 
outreg2 using "${output}tableA3.xml",  bdec(2) excel ctitle(10 yr) append


********************************************************************************
********************************************************************************
********************************************************************************
*Read-in ivol data (contains all trading days for Compustat firms)
use "${data}Compustat_Quarterly_Final", clear

keep if pre_crisis & year>=1996

egen date_tag = tag(qtr year)

keep if date_tag

gen ff4_qtr = -ff4_shock_qtr
gen ff4_d_qtr = -ff4_d_shock_qtr
gen mp1_qtr = -ffr_shock_qtr
gen mp1_d_qtr = -mp1_d_shock_qtr

qui: outreg2 using "${output}tableA2_quarterly.xls", excel dec(3) replace sum(log) eqkeep(N mean sd min max) keep(ff4_qtr ff4_d_qtr mp1_qtr mp1_d_qtr)

sum ff4_d_qtr mp1_d_qtr, detail

sum ff4_d_qtr mp1_d_qtr

